package com.ruoyi.web.controller.production;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.production.domain.SmesTechProcedure;
import com.ruoyi.mes.production.service.ISmesTechProcedureService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工艺流程管理Controller
 *
 * @author simpsense
 * @date 2020-12-02
 */
@RestController
@RequestMapping("/production/techProcedure")
public class SmesTechProcedureController extends BaseController
{
    @Autowired
    private ISmesTechProcedureService smesTechProcedureService;

    /**
     * 查询工艺流程管理列表
     */
    @PreAuthorize("@ss.hasPermi('production:techProcedure:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmesTechProcedure smesTechProcedure)
    {
        startPage();
        List<SmesTechProcedure> list = smesTechProcedureService.selectSmesTechProcedureList(smesTechProcedure);
        return getDataTable(list);
    }

    /**
     * 导出工艺流程管理列表
     */
    @PreAuthorize("@ss.hasPermi('production:techProcedure:export')")
    @Log(title = "工艺流程管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SmesTechProcedure smesTechProcedure)
    {
        List<SmesTechProcedure> list = smesTechProcedureService.selectSmesTechProcedureList(smesTechProcedure);
        ExcelUtil<SmesTechProcedure> util = new ExcelUtil<SmesTechProcedure>(SmesTechProcedure.class);
        return util.exportExcel(list, "techProcedure");
    }

    /**
     * 获取工艺流程管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:techProcedure:query')")
    @GetMapping(value = "/{techProcedureNo}")
    public AjaxResult getInfo(@PathVariable("techProcedureNo") String techProcedureNo)
    {
        return AjaxResult.success(smesTechProcedureService.selectSmesTechProcedureById(techProcedureNo));
    }

    /**
     * 新增工艺流程管理
     */
    @PreAuthorize("@ss.hasPermi('production:techProcedure:add')")
    @Log(title = "工艺流程管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmesTechProcedure smesTechProcedure)
    {
        return toAjax(smesTechProcedureService.insertSmesTechProcedure(smesTechProcedure));
    }

    /**
     * 修改工艺流程管理
     */
    @PreAuthorize("@ss.hasPermi('production:techProcedure:edit')")
    @Log(title = "工艺流程管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmesTechProcedure smesTechProcedure)
    {
        return toAjax(smesTechProcedureService.updateSmesTechProcedure(smesTechProcedure));
    }

    /**
     * 删除工艺流程管理
     */
    @PreAuthorize("@ss.hasPermi('production:techProcedure:remove')")
    @Log(title = "工艺流程管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{techProcedureNos}")
    public AjaxResult remove(@PathVariable String[] techProcedureNos)
    {
        return toAjax(smesTechProcedureService.deleteSmesTechProcedureByIds(techProcedureNos));
    }
}